<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Common\Dao\System;

use App\Common\Dao\BaseDao;
use App\Model\CustomerRoles;

class CustomerRolesDao extends BaseDao
{
    public function search(array $where)
    {
        return CustomerRoles::when(isset($where['id']) && $where['id'] != '', function ($query) use ($where) {
            $query->where('id', $where['id']);
        })->when(isset($where['role_name']) && $where['role_name'] != '', function ($query) use ($where) {
            $query->where('role_name', 'like', '%' . $where['role_name'] . '%');
        });
    }

    protected function getModel(): CustomerRoles
    {
        return new CustomerRoles();
    }
}
